<?php
namespace api\modules\v3\controllers;

use api\behaviors\controllers\BaseController;
use yii\rest\ActiveController;
use common\models\Article;
use yii\web\Response;

class ArticleController extends BaseController
{
    public $modelClass = 'common\models\Article';  
    
    public function behaviors()
    {
        $behaviors = parent::behaviors();
        $behaviors['contentNegotiator']['formats']['text/html'] = Response::FORMAT_HTML;
        //$behaviors['authenticator']['optional'] = ['index']; // 不需要登录的方法
        return $behaviors;
    }

    public  function actions()
    {
        $actions = parent::actions();
        unset($actions['index']);
        return $actions;
    }
    public function actionIndex()
    {
        $aObj = Article::find()->one();
        $result = '<h3>'.$aObj->title.'</h3><p>'.$aObj->content.'</p>';
        return $result;
    }
}